package Controller;

import Pojo.Room;
import Service.impl.RoomServiceImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RoomQueryByIdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String roomIdGet=request.getParameter("roomId");
        RoomServiceImpl roomService=new RoomServiceImpl();
        Integer roomId=Integer.parseInt(roomIdGet);
        Room room=roomService.RoomQueryById(roomId);
        response.getWriter().print(JSON.toJSONString(room));
    }
}
